package org.raymond.iworks.study.mq.kafka.demo;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.raymond.iworks.apis.avro.LogModel;
import org.raymond.iworks.apis.avro.LogModelToString;

import java.time.Instant;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
@Slf4j
public class AvroTest {
    public static void main(String[] args) {
        long now = Instant.now().toEpochMilli();
        LogModel logModel = LogModel.newBuilder()
                .setClientTime(now)
                .setStartTime(now)
                .setEndTime(now)
                .setHeaders("123:123")
                .setId(123456)
                .setMethod("post")
                .setParams("a=1&b=2")
                .setRequest("{c:5}")
                .setRequestIP("127.0.0.1")
                .setRequestURI("/hello")
                .setResponse("{result:\"ok\"}")
                .setStatus("200")
                .build();
        String newLog = LogModelToString.toString(logModel);

        log.info("\n{},\n{},\nisEq:{}\n end", JSONUtil.toJsonStr(logModel), JSONUtil.toJsonStr(newLog), logModel.equals(newLog));
    }
}
